package com.dianping.cat.home.server.transform;

import com.dianping.cat.home.server.entity.Group;
import com.dianping.cat.home.server.entity.Item;
import com.dianping.cat.home.server.entity.Segment;
import com.dianping.cat.home.server.entity.ServerMetricConfig;
import org.xml.sax.Attributes;





public class DefaultSaxMaker
  extends Object
  implements IMaker<Attributes>
{
  public Group buildGroup(Attributes attributes) {
/* 18 */     String id = attributes.getValue("id");
/* 19 */     return new Group(id);
  }



  
  public Item buildItem(Attributes attributes) {
/* 26 */     String id = attributes.getValue("id");
/* 27 */     return new Item(id);
  }



  
  public Segment buildSegment(Attributes attributes) {
/* 34 */     String id = attributes.getValue("id");
/* 35 */     String category = attributes.getValue("category");
/* 36 */     String type = attributes.getValue("type");
/* 37 */     Segment segment = new Segment(id);

/* 39 */     if (category != null) {
/* 40 */       segment.setCategory(category);
    }
    
/* 43 */     if (type != null) {
/* 44 */       segment.setType(type);
    }
    
/* 47 */     return segment;
  }


  
/* 52 */   public ServerMetricConfig buildServerMetricConfig(Attributes attributes) { return new ServerMetricConfig(); }




  
  protected <T> T convert(Class<T> type, String value, T defaultValue) {
/* 59 */     if (value == null || value.length() == 0) {
/* 60 */       return defaultValue;
    }
    
/* 63 */     if (type == Boolean.class || type == boolean.class)
/* 64 */       return (T)Boolean.valueOf(value); 
/* 65 */     if (type == Integer.class || type == int.class)
/* 66 */       return (T)Integer.valueOf(value); 
/* 67 */     if (type == Long.class || type == long.class)
/* 68 */       return (T)Long.valueOf(value); 
/* 69 */     if (type == Short.class || type == short.class)
/* 70 */       return (T)Short.valueOf(value); 
/* 71 */     if (type == Float.class || type == float.class)
/* 72 */       return (T)Float.valueOf(value); 
/* 73 */     if (type == Double.class || type == double.class)
/* 74 */       return (T)Double.valueOf(value); 
/* 75 */     if (type == Byte.class || type == byte.class)
/* 76 */       return (T)Byte.valueOf(value); 
/* 77 */     if (type == Character.class || type == char.class) {
/* 78 */       return (T)Character.valueOf(value.charAt(0));
    }
/* 80 */     return (T)value;
  }
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/classes/!/com/dianping/cat/home/server/transform/DefaultSaxMaker.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */